#!/bin/bash
###################### USAGE ###################### 
# sh init                       				  #
###################################################

SCRIPT_PATH=`pwd`
BIPLIST=`python -m pip list --format=columns | grep biplist`
PIP=`which pip2`

if [[ -z ${BIPLIST} ]]; then
	echo '--biplist--not--installed--'
	if [[ -z ${PIP} ]]; then
		echo '--PIP--not--installed--'
		brew install python2
		PIP=`which pip2`
	fi
	sudo pip2 install biplist
fi

EXPERT_PATH='export PATH=$PATH:'${SCRIPT_PATH}
chmod a+x ${SCRIPT_PATH}/*
SHELL_NAME=`echo ${SHELL} | cut -d / -f3`
LAST_PATH=`tail -n 1 ~/.${SHELL_NAME}rc`
if [[ ${LAST_PATH} != ${EXPERT_PATH} ]]; then
	echo 'export PATH=$PATH:'${SCRIPT_PATH} >> ~/.${SHELL_NAME}rc
fi

export PATH=$PATH:${SCRIPT_PATH}

echo 'init env successfully'
